﻿using System;
using WiMo.Games.Drawables;

namespace WiMo.Games
{
    public class Displayd
    {
        public const byte AspetRatioAny = 0xFF;
        public const byte AspetRatioOneByOne = 0x02;
        public const byte AspetRatioFourByThree = 0x04;
        public const byte AspetRatioThreeByFour = 0x08; 
    }

    public enum DisplayStrategies
    {
        MostlyStatic,
        MostlyDynamic,
        Automatic
    }

    public interface IDisplay: IDisposable
    {
        DisplayStrategies DisplayStrategy { get; set; }

        byte AspectRatio { get; set; }

        int DPI { get; set; }

        string Name { get; }

        ITexture BackgroundImage { get; set; }
        Color BackgroundColor { get; set; }
        void Reset();

        void Add(IDrawable drawable);

        ISpriteLine DrawLine(Location start, Location end, Color color, int width);        
        ISpriteText DrawText(PointF position, string text, ISpriteFont font, Color foreColor);
        ISpriteText DrawText(PointF position, string text, ISpriteFont font, Color foreColor, Origin origin);

        ISpriteShape DrawRectangle(Rectangle rect, Color color, int width);
        ISpriteShape DrawRectangle(Rectangle rect, Color color, int width, Origin origin);        

        ISpriteShape DrawCircle(PointF position, int radius, Color borderColor, int width);

        ISpriteShape FillRectangle(Rectangle rect, Color fillColor, Color borderColor, int width);
        ISpriteShape FillRectangle(Rectangle rect, Color fillColor, Color borderColor, int width, Origin origin);
        ISpriteShape FillCircle(PointF position, int radius, Color fillColor, Color borderColor, int width);
        
        void Render(ISpriteImage sprite);
        void Render(ISpriteText text);
        void Render(ISpriteShape shape);
        void Render(ISpriteLine line);

        bool Diagnostics { get; set; }

        void Render();
        void Invalidate();

        void Resize(Size bounds);

        /// <summary>
        /// If the display is scaled based upon a DPI it is centered in the screen
        /// </summary>
        Location DisplayOffset { get; }
        Size Size { get; }
        Size TargetSize { get; }
        Vector2 ScaleFactor { get; }

        ISpriteImage CreateSpriteImage();
        ISpriteShape CreateRectangle();
        ISpriteText CreateText();
        ISpriteLine CreateLine();
        ISpriteShape CreateEllipse();
        ISpriteShape CreateLineList();
        ISpriteShape CreatePolygon();
    }
}
